There is a race condition between domain_create_ring() and the removal
of the domU entry from xenstore. If the removal of the domU entry from xenstore
comes later than the first xs_gather() call in domain_create_ring(), it will go
on and bind the evtchn port to the dying domU, which will cause below error
message: (XEN) (file=event_channel.c, line=144) EVTCHNOP failure: domain 0, error -22, line 144
Signed-off-by: Max Zhen <max.zhen@sun.com>
bool success;
sprintf(domid_str, "dom%u", dom->domid);
- if (watch)
+ if (watch) {
success = xs_watch(xs, dom->conspath, domid_str);
- else
+ if (success)
+ domain_create_ring(dom);
+ } else {
success = xs_unwatch(xs, dom->conspath, domid_str);
- if (success)
- domain_create_ring(dom);
+ }
+
return success;
}